﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using MediaService.ServiceContract;
using System.ServiceModel;

namespace MediaServer
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private ServiceHost cctvSericeHost =  null;
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //Uri baseNetTCPAddress = new Uri("net.tcp://localhost:5000/");
                cctvSericeHost = new ServiceHost(typeof(MediaService.ServiceContract.MediaService));

                cctvSericeHost.Open();
                if (cctvSericeHost.State == CommunicationState.Opened)
                    txtInfo.Text = "服务已启动。";
            }
            catch (Exception myE)
            {
                txtInfo.Text = "运行服务出错：\r\n\r\n" + myE.InnerException == null ? myE.Message : myE.InnerException.Message;
            }
        }
    }
}
